package com.llmops.core.node;

import com.llmops.core.Node;
import com.llmops.core.Context;
import com.llmops.core.NodeProperty;
import lombok.Data;

import java.util.Map;

public class EndNode extends Node {
    private EndNode.OutputNodeProperty property = new EndNode.OutputNodeProperty();

    @Data
    public static class OutputNodeProperty extends NodeProperty {
        private String prompt;
    }
    public EndNode(String id, String title, Map<String, Object> config) {
        super(id, title,config);
        property.setPrompt((String)config.get("content"));
    }

    @Override
    public void execute(Context context) {
        String out = context.fillVariable(context,property.getPrompt());
        context.setVariable(id + "_output", out);
        logger.info(getId() + "_output={}", out);
    }

    @Override
    public String getType() {
        return "end";
    }
}